package org.mca.mcaweb.interceptor;

import java.io.Serializable;

import javax.inject.Inject;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;

import org.mca.mcaweb.annotation.Logger;
import org.mca.mcaweb.dao.LogDAO;

@Interceptor
@Logger
public class LoggerInterceptor implements Serializable {

	private static final long serialVersionUID = 8000653094448543214L;

	@Inject
	private LogDAO logDAO;
	
	@AroundInvoke
	public Object intercept(InvocationContext ctx) throws Exception {
		
		Object resultado = null;
		
		resultado = ctx.proceed();
		
		logDAO.registerLog(ctx);
			
		return resultado;
	}
}
